package com.xinchuang.mapper.targetSystem;

import com.xinchuang.entity.targetSystem.system.SystemMaster;
import com.xinchuang.entity.targetSystem.system.SystemsMaster;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @ClassName SystemSortMapper
 * @Description: TODO(写一段描述的话)
 * @Author zhangxuan
 * @Date 2023-08-07 17:42
 * @Verion V1.0
 */
public interface SystemSortMapper {

    @Select(value = "SELECT MIN(sort) FROM system_master")
    Integer getSystemMin();

    @Select(value = "SELECT MAX(sort) FROM system_master")
    Integer getSystemMax();

    @Select(value = "SELECT s_id AS sId,sort FROM system_master WHERE sort < #{sort} ORDER BY sort DESC LIMIT 1")
    SystemMaster getSystemLT(Integer sort);

    @Select(value = "SELECT s_id AS sId,sort FROM system_master WHERE sort > #{sort} ORDER BY sort ASC LIMIT 1")
    SystemMaster getSystemGT(Integer sort);

    @Update(value = "UPDATE system_master SET sort = #{sort} WHERE s_id = #{id}")
    int updateSystem(String id, Integer sort);

    @Select(value = "SELECT MIN(sort) FROM systems_master")
    Integer getSystemsMin();

    @Select(value = "SELECT MAX(sort) FROM systems_master")
    Integer getSystemsMax();

    @Select(value = "SELECT sys_id AS sysId,sort FROM systems_master WHERE sort < #{sort} ORDER BY sort DESC LIMIT 1")
    SystemsMaster getSystemsLT(Integer sort);

    @Select(value = "SELECT sys_id AS sysId,sort FROM systems_master WHERE sort > #{sort} ORDER BY sort ASC LIMIT 1")
    SystemsMaster getSystemsGT(Integer sort);

    @Update(value = "UPDATE systems_master SET sort = #{sort} WHERE sys_id = #{id}")
    int updateSystems(String id, Integer sort);

}
